package clone.foundation;

import cn.hutool.core.clone.CloneSupport;
public class Test2 {
    public static void main(String[] args) {
        Cat cat1 = new Cat("miaomiao",2);
        Cat cat2 = cat1.clone();
        System.out.println(cat1.toString() + cat2.toString());
        // 改变cat2的值，cat1不会变
        cat2.setAge(88);
        System.out.println(cat1.toString() + cat2.toString());
    }
}
class Cat extends CloneSupport<Cat> {
    private String name;
    private int age;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public Cat(String name, int age){
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "name:" + name + "age:" + age;
    }
}
